﻿using Avalonia;
using SharpWebview.Content;
using SharpWebview;
using System;

namespace Ava.Demo
{
    internal sealed class Program
    {
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        [STAThread]
        public static void Main(string[] args)
        {
            BuildAvaloniaApp()
            .StartWithClassicDesktopLifetime(args);
            //using (var webview = new Webview(true))
            //{
            //    webview
            //        // Set the title of the application window
            //        .SetTitle("The Hitchhicker")
            //        // Set the start size of the window                
            //        .SetSize(1024, 768, WebviewHint.None)
            //        // Set the minimum size of the window
            //        .SetSize(800, 600, WebviewHint.Min)
            //        // This script gets executed after navigating to the url
            //        .InitScript("window.x = 42;")
            //        // Bind a c# function to the webview - Accessible with the name "evalTest"
            //        .Bind("evalTest", (id, req) =>
            //        {
            //            // Executes the javascript on the webview
            //            webview.Evaluate("console.log('The anwser is ' + window.x);");
            //            // And returns a successful promise result to the javascript function, which executed the 'evalTest'
            //            webview.Return(id, RPCResult.Success, "{ result: 'We always knew it!' }");
            //        })
            //        // Navigate to this url on start
            //        .Navigate(new UrlContent("https://www.baidu.com"))
            //        // Run the webview loop
            //        .Run();
            //}
        }
        // Avalonia configuration, don't remove; also used by visual designer.
        public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>()
                .UsePlatformDetect()
                .WithInterFont()
                .LogToTrace();
    }
}
